home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / xlibpas2.zip / XMISC2.PAS < prev    next >
Pascal/Delphi Source File  |  1994-06-08  |  1KB  |  83 lines

  1. unit xmisc2;
  2.  
  3. interface
  4.  
  5. Type
  6.     TByteArray = array[0..0] of byte;
  7.     TIntArray  = array[0..0] of integer;
  8.     TWordArray = array[0..0] of integer;
  9.  
  10. function  xinttostr( n : integer; w : byte ) : string;
  11. function  xcompare( var a, b; l : word ) : boolean;
  12. function  xexists( filename : string ) : boolean;
  13. procedure xstrupcase( var s : string );
  14.  
  15. implementation
  16.  
  17. function xinttostr( n : integer; w : byte ) : string;
  18. var
  19.     s : string;
  20. begin
  21.     str( n:w, s );
  22.     xinttostr := s;
  23. end;
  24.  
  25. function xcompare( var a, b; l : word ) : boolean; assembler;
  26. asm
  27.     cld
  28.     push ds
  29.     lds  si, a
  30.     les  di, b
  31.     mov  cx, l
  32.     repe cmpsb
  33.     or   cx, cx
  34.     jz   @@Ok
  35.     mov  ax, 0
  36.     jmp  @@Done
  37.  
  38. @@Ok:
  39.     mov  ax, 1
  40.  
  41. @@Done:
  42.     pop  ds
  43.  
  44. end;
  45.  
  46. function xexists( filename : string ) : boolean;
  47. var
  48.     f : file;
  49.     tmp : boolean;
  50. begin
  51.     {$I-}
  52.     assign( f, filename );
  53.     reset( f );
  54.     {$I+}
  55.     tmp := ioresult=0;
  56.     if tmp then close(f);
  57.     xexists := tmp;
  58. end;
  59.  
  60. procedure xstrupcase( var s : string ); assembler;
  61. asm
  62.     les di, s
  63.     mov cx, 0
  64.     mov cl, es:[di]
  65.     inc di
  66.     or  cl, cl
  67.     jz @@Done
  68.  
  69. @@ChangeChar:
  70.     mov al, es:[di]
  71.     cmp al, 'a'
  72.     jl @@Next
  73.     cmp al, 'z'
  74.     jg @@Next
  75.     sub al, 32
  76.     mov es:[di], al
  77. @@Next:
  78.     inc di
  79.     loop @@ChangeChar
  80. @@Done:
  81. end;
  82.  
  83. end.